<?php

namespace hiduoke\services\formBuilder;

use FormBuilder\Driver\FormComponent;
use FormBuilder\Factory\Elm;

class DkAddonSelect extends FormComponent
{

    public function createValidate()
    {
        return Elm::validateObject();
    }

    /**
     * Dialog 自身是否插入至 body 元素上。
     * @return DkAddonSelect
     */
    public function appendToBody()
    {
        return $this->props(['appendToBody' => true]);
    }

    public function addonsExplain($addons = [])
    {
        return $this->props(['addonsExplain' => $addons]);
    }

    public function data($data)
    {
        return $this->props(['addonData' => $data]);
    }

    /**
     * @param null|string $message
     * @return $this
     */
    public function required($message = '请选择应用以及权限')
    {
        if (is_null($message)) $message = $this->getPlaceHolder();
        $this->appendValidate($this->createValidate()->message($message)->required());
        return $this;
    }
}